layui.use('laydate', function(){
	  var laydate = layui.laydate;
	  
	  lay('.test-item').each(function(){
		    laydate.render({
		      elem: this
		      ,trigger: 'click'
		    });
		  });
});	

layui.use('table', function(){
  var table = layui.table;
  var stid=getParameter("sellId");
  var stids=getParameter("purchaseId");
  console.log(stid)
  console.log(stids)
  //监听表格复选框选择
  table.on('checkbox(demo)', function(obj){
    console.log(obj)
  });
  //表单重载
  var $ = layui.$, active = {
		    reload: function(){
		      
		      //执行重载
		      table.reload('idTest', {
		        page: {
		          curr: 1 //重新从第 1 页开始
		        }
		        ,where: {
		        	purchaseId: getParameter("purchaseId"),
		        	sellId: getParameter("sellId")
		        }
		      });
		    }
		  };
  
  

  active['reload'] ? active['reload'].call(this) : '';
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});
/**
 * 从地址栏传值的代码
 * @param param
 * @returns
 */
function getParameter(param){
	var query = window.location.search;
	var iLen = param.length;
	var iStart = query.indexOf(param);
	if (iStart == -1)
		return "";
	iStart += iLen + 1;
	var iEnd = query.indexOf("&", iStart);
	if (iEnd == -1)
		return query.substring(iStart);
	return query.substring(iStart, iEnd);
}